package com.example.springboot.mapper;

import com.example.springboot.entity.Seat;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

/**
 * <p>
 * 座位管理 Mapper 接口
 * </p>
 *
 * @author 
 * @since 
 */
public interface SeatMapper extends BaseMapper<Seat> {
    // SeatMapper.java 新增接口
    @Select("SELECT COUNT(*) FROM seat WHERE id=#{seatId} " +
            "AND status IN ('RESERVED','IN_USE') " +  // 修正RESERVED拼写
            "AND ((start_time <= #{end} AND end_time >= #{start}))")
    int checkConflict(@Param("seatId") Integer seatId,
                      @Param("start") LocalDateTime start,
                      @Param("end") LocalDateTime end);



}
